<?php

/**
 * Description of EnhablingPlugin
 *
 * @author JeyDotC
 * @export Plugins
 */
class EnhablingPlugin extends UnderscorePlugin implements ReplaceTask {

    private $action;

    public function replaceTask() {
        return $this->action;
    }

    public function willReplaceTask($task) {
        $module = $this->getModule()->getName();

        $modulesConfig = ModulesContext::instance()->getConfig()->get("Modules", array());

        if (array_key_exists($module, $modulesConfig)) {
            $moduleConfig = $modulesConfig[$module];
            if (array_key_exists("disabled", $moduleConfig)) {
                $this->action = isset($moduleConfig["action"]) ? $moduleConfig["action"] : "";
            }
        }

        $willReplace = !empty($this->action);
        return $willReplace;
    }

}

?>
